# alist = [1, 2, 3, 4]
# print(alist[2])
# alist = [1, 2, 3, 4]
# print(alist[len(alist)-1])

# alist = [1, 2, 3, 4]
# print(alist[1:]) # 省略后边界, 表示获取到列表末尾
# print(alist[:-1]) # 省略前边界, 表示从列表开头获取
# print(alist[:]) # 省略两个边界, 表示获取到整个列表.

#遍历
# alist = [1, 2, 3, 4]
# #方式一
# for elem in alist:
#     print(elem)
# #方式二
# for i in range(0, len(alist)):
#     print(alist[i])
# #方式三
# i = 0
# while i < len(alist):
#     print(alist[i])
#     i += 1
#增加元素
# alist = [1, 2, 3, 4]
# alist.append('hello')
# print(alist)
#查找元素
# alist = [1, 2, 3, 4]
# print(alist.index(2))
# print(alist.index(10))
# #删除末尾元素和指定元素
# alist = [1, 2, 3, 4]
# alist.pop()
# print(alist)
# alist.pop(1)
# print(alist)
#remove方法，可以删除指定的数值
# alist = [1, 2, 3, 4]
# alist.remove(2)
# print(alist)
# alist.remove(10)
# print(alist)
#连接列表
alist = [1, 2, 3, 4]
blist = [5, 6, 7]
print(alist + blist)
alist.extend(blist)
print(alist)
print(blist)